﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Common;

namespace Library
{
    public partial class UsersBorrowed : Form
    {
        public event SelectItem SelectUserName;
        public DataGridView AllBorrowedCopieByUser_dgv
        { get{ return allBorrowedCopiesByUser_dgv; }  }
        public List<Guid> returnedItem;
        

        public UsersBorrowed(List<User> users)
        {
            InitializeComponent();
            allUsers_ltbx.DataSource = users;
            returnedItem = new List<Guid>();
        }

        private void allUsers_ltbx_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (SelectUserName != null)
            {
                SelectUserName(sender, e);
            }
        }
        private void allBorrowedCopiesByUser_dgv_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            copieID_txbx.Text = allBorrowedCopiesByUser_dgv["CopyID", e.RowIndex].Value.ToString(); //может быть CopieID
        }
        private void returnItem_btn_Click(object sender, EventArgs e)
        {
            if (copieID_txbx.Text != string.Empty)
                returnedItem.Add(new Guid(copieID_txbx.Text)); 
        }

        private void close_btn_Click(object sender, EventArgs e)
        {
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }
    }
}
